package file;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Test4 {

        public static void main(String[] args) {
            Scanner scan=new Scanner(System.in);
            System.out.println("输入文件名:");

            while (scan.hasNext()){
                File file=new File("./"+scan.next()+".txt");
                if (file.exists()){
                    System.out.println("文件已存在，请更换文件:");
                }else {
                    try {
                        file.createNewFile();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    System.out.println("文件已创建,将结束进程");
                    break;
                }
            }
        }
        }

